package com.candy.test;

import java.util.Scanner;

public class zy01 {
    public static void main(String[] args) {
        System.out.println("请输入一个1~1000的整数：");
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        if(a<1||a>1000){
            System.out.println("数据无效");
        }else {
            int b, c, d, e, sum;
            e = a / 1000;
            d = a / 100 % 10;
            c = a / 10 % 10;
            b = a % 10;
            sum = b + c + d + e;
            System.out.println("结果为：" + sum);
        }
    }
}
